package fhp.hlhj.giantfold.module

import com.lzy.okgo.model.HttpParams
import fhp.hlhj.giantfold.javaBean.GoodListBean
import fhp.hlhj.giantfold.javaBean.MallBean
import fhp.hlhj.giantfold.network.UrlApis

/**
 * author: FHP
 * data: on 2018\1\16 0016 13:49
 * E-Mail: 103945089@qq.com
 */
class MallModule {
    interface MallListener{
        fun showLoading()
        fun onMallListener(mallBean: MallBean)
        fun onGoodsListenr(goodListBean: GoodListBean)
    }
    /**
     * 获取菜单列表
     */
    fun getMall(params: HttpParams,listener: MallListener){
        UrlApis.getMall(params)
                .doOnSubscribe {
                    listener.showLoading()
                }
                .subscribe {
                    data->
                    listener.onMallListener(data)
                }
    }
    /**
     * 获取商品列表
     */
    fun getGood(params: HttpParams,listener: MallListener){
        UrlApis.getGood(params)
                .doOnSubscribe {
                    listener.showLoading()
                }
                .subscribe ({
                    data->
                    listener.onGoodsListenr(data)
                },{
                    data->
                    data.printStackTrace()
                })
    }
}